import { defineStore } from 'pinia'
import { storage } from '@/utils'

export const useGoodsHistoryStore = defineStore('goodsHistory', () => {
	const historyListKey = 'historyListKey'
	
	const getHistoryList = () => storage.getLocalStorage(historyListKey)
	
	const setHistoryList = (val:string) => {
		const historyList = getHistoryList() || []
		historyList.push(val)
		storage.setLocalStorage(historyListKey, historyList)
	}
	
	const delHistoryAll = () => {
		storage.setLocalStorage(historyListKey, null)
	}
	
	return {
		getHistoryList,
		setHistoryList,
		delHistoryAll
	}
})